﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Restaurant.entity;

namespace Restaurant
{
    public partial class menuC : UserControl
    {
        public menuC()
        {
            InitializeComponent();
        }

        public string n;
        public string p;
        public int index;

        public int table_id;
        public int tableid { get { return table_id; } set { table_id = value; } }
        public string name { get { return n; }set { n = value; } }
        public string price { get { return p; } set { p = value; } }

        public int picindex { get { return index; } set { index = value; } }

        private void menuC_Load(object sender, EventArgs e)
        {
            label1.Text = name;
            label2.Text = "￥"+price;
            switch(picindex)
            {
                case 100: pictureBox1.Image = Properties.Resources.i__1_;break;
                case 101: pictureBox1.Image = Properties.Resources.i__2_; break;
                case 102: pictureBox1.Image = Properties.Resources.i__3_; break;
                case 103: pictureBox1.Image = Properties.Resources.i__4_; break;
                case 104: pictureBox1.Image = Properties.Resources.i__5_; break;
                case 105: pictureBox1.Image = Properties.Resources.i__6_; break;
                case 106: pictureBox1.Image = Properties.Resources.i__7_; break;
                case 107: pictureBox1.Image = Properties.Resources.i__8_; break;
                case 108: pictureBox1.Image = Properties.Resources.i__9_; break;
                default: pictureBox1.Image = Properties.Resources.i__1_; break;
            }
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Menuitem m = new Menuitem(name,picindex,Convert.ToDouble(price));
            SData.Glistusing[SData.Getindex(SData.table[tableid])].menuitems.Add(m);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int index = SData.Glistusing[SData.Getindex(SData.table[tableid])].getMenuindex(picindex);
            if(index!=-1)
            SData.Glistusing[SData.Getindex(SData.table[tableid])].menuitems.RemoveAt(index);
        }
    }
}
